<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/element-ui/2.15.9/theme-chalk/index.css">
    <style>
        a{text-decoration: none;font-size: 14px;text-align: center}
        a:link{color:#cccccc }
        a:hover{color: white}
        .center{width: 1200px;margin: 0 auto}
        .el-dropdown-link {
            cursor: pointer;
            color: #409EFF;
        }
        .el-icon-arrow-down {
            font-size: 12px;
        }
        .el-select .el-input {
            width: 130px;
        }
        .input-with-select .el-input-group__prepend {
            background-color: #fff;
        }
        ul{
            list-style-type: none;
            overflow: hidden;/*解决高度为0 导致的异常*/
        }
        li{
            float: left;
            margin-right: 10px;
        }
    </style>
</head>
<body>
<div id="app">
    <el-container>
        <my-header></my-header>
        <el-main style="background-image: url('imgs/login-background.png');height: 500px;background-size: cover;background-position: center;">
            <el-card style="width: 500px;height: 300px;;margin: 50px auto">
                <el-form label-width="80px" style="width: 400px;margin: 10px auto">
                    <el-form-item style="margin-bottom: 10px">
                        <a style="float: right;
                                text-decoration: none;color: #409EFF;
                                position: relative;top: 20px"  href="/findPassword.html">
                            忘记密码?找回密码
                        </a>
                    </el-form-item>
                    <el-form-item label="用户名">
                        <el-input placeholder="请输入用户名" v-model="user.userName"></el-input>
                    </el-form-item>
                    <el-form-item label="密码">
                        <el-input type="password" @keydown.native.enter="login()" placeholder="请输入用密码" v-model="user.password"></el-input>
                    </el-form-item>

                    <el-form-item>
                        <el-button type="primary" @click="login()">登录</el-button>
                    </el-form-item>
                </el-form>
            </el-card>
        </el-main>
        <el-footer style="margin: 0;padding: 0">
           <my-footer></my-footer>
        </el-footer>

    </el-container>
</div>




<!-- import Vue before Element -->
<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
<!-- import JavaScript -->
<script src="https://cdn.staticfile.org/element-ui/2.15.9/index.min.js"></script>
<!--引入Axios-->
<script src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js"></script>
<script src="js/my-header.js"></script>
<script src="js/my-footer.js"></script>

<script>
    let v = new Vue({
        el: '#app',
        data: function () {
            return {

                user:{},
            }
        },
        methods: {
            login(){
                axios.post("/v1/users/login",v.user).then(function (response) {
                    if(response.data.code==1){
                        v.$message.success("登录成功!")
                        localStorage.user=JSON.stringify(response.data.data);
                        location.href="/"
                        return
                    }else{
                        v.$message.error(response.data.msg)
                    }
                })
            }
        },

    })
</script>
</body>
</html>